home *** CD-ROM | disk | FTP | other *** search
/ DS-CD ROM 2 1993 August / DS CD-ROM 2.Ausgabe (August 1993).iso / programm / ds0256 / mdebug1.exe / KONVERT.A86 < prev    next >
Text File  |  1992-11-20  |  3KB  |  137 lines

  1. ; ----------------------------
  2. ; KONVERT
  3. ;
  4. ; Enthält:         Assembler-Routinen zur Konvertierung von Werten in Hexstrings
  5. ;
  6. ; Autor:           Bernd Schemmer
  7. ;                  Jahnstr. 58
  8. ;                  6000 Frankfurt 1
  9. ;                  Tel.: (069) 59 54 57
  10. ;
  11. ; System:          IBM-PC/AT/Kompatibler
  12. ; Hardware:        -
  13. ; Betriebs-System: DOS 3.xx
  14. ; Sprache:         Assembler
  15. ; Compiler:        A86
  16. ;
  17. ; Letzter Update:  12.07.1992
  18. ;
  19. ; Besonderheiten:  Alle Routinen sind als FAR-Routinen kodiert
  20. ;
  21. ; Übersetzen:      A86 KONVERT.A86 to KONVERT.OBJ
  22. ;
  23. ; ----------------------------
  24.  
  25. CODE SEGMENT BYTE PUBLIC
  26.      ASSUME CS:CODE
  27.  
  28. ; ----------------------------
  29.  
  30. PUBLIC HexByte
  31. PUBLIC HexWord
  32.  
  33. ; ----------------------------
  34. ; HexByte
  35. ;
  36. ; Funktion:           Umwandeln eines Bytes in einen HexString
  37. ;
  38. ; Pascal-Deklaration: {$F+} FUNCTION HexByte(zahlb : BYTE):STRING; EXTERNAL; {$F-}
  39. ;
  40. ; Eingabe-Parameter:  zahlb - Umzuwandelndes Byte
  41. ;
  42. ; Ausgabe-Parameter:  Als Funktions-Wert wird der HexString zurueckgegeben
  43. ;
  44. ; Besonderheiten:     Der Funktions-Wert ist immer 2 Zeichen lang
  45. ;
  46.  
  47. zahlb EQU [BP+06h]            ; Offsets der Parameter auf dem Stack
  48. str2  EQU [BP+08h]
  49.  
  50. HexByte PROC FAR
  51.          push bp
  52.          mov bp,sp
  53.          cld
  54.          les di,str2
  55.          mov b es:[di],02h
  56.          inc di
  57.          mov al,zahlb
  58.          call Konvert_AL_TO_AX
  59.          stosw
  60.  
  61.          pop bp
  62.          retf 2
  63.  
  64. ; ----------------------------
  65. ; HexWord
  66. ;
  67. ; Funktion:           Umwandeln eines Wortes in einen HexString
  68. ;
  69. ; Pascal-Deklaration: {F+} FUNCTION HexWord(zahlw : WORD):STRING; EXTERNAL; {$F-}
  70. ;            
  71. ; Eingabe-Paramter:   zahlw - umzuwandelndes Wort
  72. ;
  73. ; Augabe-Paramter:    Als Funktions-Wert wird der HexString zurueckgegeben
  74. ;
  75. ; Besonderheiten:     Der Funktions-Wert ist immer 4 Zeichen lang
  76. ;
  77.  
  78. zahlw EQU [BP+06]             ; Offsets der Parameter auf dem Stack
  79. str4  EQU [BP+08]
  80.  
  81. HexWord PROC FAR
  82.          push bp
  83.          mov bp,sp
  84.          cld
  85.          les di,str4
  86.          mov b es:[di],4
  87.          inc di
  88.  
  89.          mov ax,zahlw
  90.          push ax
  91.          mov al,ah
  92.          call Konvert_AL_TO_AX
  93.          stosw
  94.          pop ax
  95.          call Konvert_AL_TO_AX
  96.          stosw
  97.          pop bp
  98.          retf 2
  99.  
  100. ; ---------------------------
  101. ; Konvert_AL_To_AX
  102. ;
  103. ; Funktion: Konvertiert AL in einen Hexstring
  104. ;
  105. ; Eingabe:  AL = zu konvertierender Wert
  106. ;
  107. ; Ausgabe:  AL = oberes Nibble als Hexziffer
  108. ;           AH = unteres Nibble als Hexziffer
  109. ;
  110. Konvert_AL_TO_AX PROC NEAR
  111.          mov ah,al
  112.          and ah,0F0h
  113.          shr ah,1
  114.          shr ah,1
  115.          shr ah,1
  116.          shr ah,1
  117.          cmp ah,9xD
  118.          jg >l1
  119.          add ah,'0'
  120.          jmp >l2
  121. l1:
  122.          add ah,'7'
  123. l2:
  124.          and al,0Fh
  125.          cmp al,9xD
  126.          jg >l1
  127.          add al,'0'
  128.          jmp >l2
  129. l1:
  130.          add al,'7'
  131. l2:
  132.          xchg ah,al
  133.          ret
  134.  
  135.          CODE ENDS
  136. ; ----------------------------
  137.